/**
 * Created by on 22/01/18.
 */

/**
 * 获取对应的json文件数据
 * @param {string} value
 * @param {string} type
 * @returns {string}
 */
export function getArea() {
  var Data = require('../assets/json/chinaArea.json')
  if (Data) {
    return Data
  } else {
    return false
  }
}
export function codeToText(arr) {
  var Data = require('../assets/json/chinaArea.json')
  if (Data && arr instanceof Array) {
    if (arr.length === 3) {
      var str = ''
      for (const n in Data) {
        console.log(n)
        console.log(arr[0])
        if (Data[n].value === arr[0]) {
          str = Data[n].label
          for (const s in Data[n].children) {
            if (Data[n].children[s].value === arr[1]) {
              str += '/' + Data[n].children[s].label
              for (const m in Data[n].children[s].children) {
                if (Data[n].children[s].children[m].value === arr[2]) {
                  str += '/' + Data[n].children[s].children[m].label
                  break
                }
              }
              break
            }
          }
          break
        }
      }
      return str
    } else {
      return arr
    }
  } else {
    return arr
  }
}

